<h2>Image Infrastructure Installation Procedure</h2>
<h3>1.MySQL</h3>
<ul>
	  <li>Server: vm043.dev.hk3.tvb.com(ip:202.126.59.205)</li>
  <li>User account 
    <ul>
      <li>[root@*]# mysql -uroot -p</li>
      <li>mysql> CREATE DATABASE image;</li>
      <li>mysql> GRANT ALL ON image.* TO 'tvb_image'@'%' IDENTIFIED BY 'tvb_image';</li>
      <li>mysql> FLUSH PRIVILEGES;</li>
    </ul>
  <li>DB Schema Initial Data
    <ul>
      <li>[root@*]# mysql -uroot -p image < schema.sql</li>
      <li>[root@*]# mysql -uroot -p image < init_data.sql</li>
    </ul>
  </li>
</ul>
<h3>2.Web Service API</h3>
<ul>
  <li>Server: ii.api.tvb.com (vm042.dev.hk3.tvb.com-&gt;ip:202.126.59.204)
    <ul>
      <li>[root@*]# yum install tvb_image_infrastructure_web_service_server</li>
      <li>[root@*]# /sbin/service httpd restart</li>
    </ul>
  </li>
  <li>Update config if needed (/data/image_infrastructure/config/server.xml)</li>
  <li>Mount Share Drive</li>
  <li>Restart Apache
    <ul>
      <li>[root@*]# /sbin/service httpd restart</li>
    </ul>
  </li>
</ul>
<h3>3.Processing Farm</h3>
<ul>
  <li>Server: vm042.dev.hk3.tvb.com
    <ul>
      <li>[root@*]# yum install tvb_image_infrastructure_export_image_consumer</li>
      <li>[root@*]# yum install tvb_image_infrastructure_distribute_tvb_img_farm_image_consumer </li>
    </ul>
  </li>
  <li>Update config if needed    </li>
  <li>Mount Share Drive    </li>
  <li>Install Public Key and Private Key to distribute files to IMG Farm
    <ul>
      <li>/data/image_infrastructure/config/distribute_tvb_img_farm_image/id_rsa.pub        </li>
      <li>/data/image_infrastructure/config/distribute_tvb_img_farm_image/id_rsa </li>
    </ul>
  </li>
  <li>Restart Consumer 
    (/data/image_infrastructure/config/server.xml,
    /data/image_infrastructure/config/export_image/consumer.xml,
    /data/image_infrastructure/config/distribute_tvb_img_farm_image/img_farm.xml)
    <ul>
      <li>[root@*]# /sbin/service export_image_consumer restart </li>
      <li>[root@*]# /sbin/service distribute_tvb_img_farm_image_consumer restart </li>
      <li>[root@*]# /sbin/service recall_image_tvb_img_farm_consumer restart </li>
    </ul>
  </li>
  <li>(TODO: repackage consumer packages, add dependency in pear to web_service_config) </li>
</ul>
<h3>4.Web Server (Serving image with TVB-Auth Cookie checking)</h3>
<ul>
  <li>Server: ii.tvb.com (vm042.dev.hk3.tvb.com-&gt;ip:202.126.59.204)
    <ul>
      <li>[root@*]# yum install tvb_image_infrastructure_web_server </li>
    </ul>
  </li>
  <li> Mount Share Drive    </li>
  <li> Restart Apache
    <ul>
      <li>[root@*]# /sbin/service httpd restart </li>
    </ul>
  </li>
</ul>
<h3>5.Client</h3>
<ul>
  <li>Server: any server need II
    yum install tvb_image_infrastructure_client_pear  </li>
</ul>
<h3>6.Verify Setup</h3>
<ul>
  <li>Install PHPUnit
    <ul>
      <li>pear upgrade PEAR        </li>
      <li>pear channel-discover </li>
      <li>pear.phpunit.de        </li>
      <li>pear install --alldeps phpunit/PHPUnit </li>
    </ul>
  </li>
  <li> Download unit-test case </li>
</ul>
<h3>7.IMG Farm</h3>
<ul>
  <li>Server: i[1-2].web.hk1
    <ul>
      <li>mkdir -p /data/httpd/htdocs/img.tvb.com/ii </li>
      <li>chown tvbweb.www /data/httpd/htdocs/img.tvb.com/ii </li>
      <li>mkdir -p /data/image_infrastructure/acl </li>
      <li>chown tvbweb.www /data/image_infrastructure/acl </li>
      <li>chmod 777 /data/image_infrastructure/acl </li>
    </ul>
  </li>
</ul>
<h3>8.Mount share drive</h3>
<h3>9.DSF</h3>
<ul>
  <li>Create Filer Directory
    <ul>
      <li>mkdir -p /media/content_root/1/image_infrastructure </li>
      <li>chmod -R a+rw /media/content_root/1/image_infrastructure </li>
      <li>mkdir -p /media/content_root/2/image_infrastructure </li>
      <li>chmod -R a+rw /media/content_root/2/image_infrastructure </li>
      <li>mkdir -p /media/content_root/3/image_infrastructure </li>
      <li>mkdir -p /media/content_root/4/image_infrastructure </li>
      <li>chmod -R a+rw /media/content_root/3/image_infrastructure </li>
      <li>chmod -R a+rw /media/content_root/4/image_infrastructure </li>
    </ul>
  </li>
  <li>Symlink Filer Directory to II image dir
    <ul>
      <li>mkdir -p /data/image_infrastructure/image </li>
      <li>ln -s /media/content_root/1/image_infrastructure /data/image_infrastructure/image/1 </li>
      <li>ln -s /media/content_root/2/image_infrastructure /data/image_infrastructure/image/2 </li>
      <li>ln -s /media/content_root/3/image_infrastructure /data/image_infrastructure/image/3 </li>
      <li>ln -s /media/content_root/3/image_infrastructure /data/image_infrastructure/image/4 </li>
    </ul>
  </li>
</ul>
<h3>10.Production</h3>
<ul>
  <li>Create Filer Directory
    <ul>
      <li>mkdir /media/content1/image_infrastructure </li>
      <li>chmod -R a+rw /media/content1/image_infrastructure </li>
      <li>mkdir /media/content2/image_infrastructure </li>
      <li>chmod -R a+rw /media/content2/image_infrastructure </li>
      <li>mkdir /media/content3/image_infrastructure </li>
      <li>chmod -R a+rw /media/content3/image_infrastructure </li>
      <li>mkdir /media/content4/image_infrastructure </li>
      <li>chmod -R a+rw /media/content4/image_infrastructure </li>
    </ul>
  </li>
  <li>Symlink Filer Directory to II image dir
    <ul>
      <li>mkdir -p /data/image_infrastructure/image        </li>
      <li>ln -s /media/content1/image_infrastructure /data/image_infrastructure/image/1        </li>
      <li>ln -s /media/content2/image_infrastructure /data/image_infrastructure/image/2        </li>
      <li>ln -s /media/content3/image_infrastructure /data/image_infrastructure/image/3        </li>
      <li>ln -s /media/content3/image_infrastructure /data/image_infrastructure/image/4</li>
    </ul>
  </li>
</ul>
